require(['jquery', 'cookie', 'app', 'lay','base64'], function ($) {
    require(['vue'], function (Vue) {
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where:{}
            }
            , created: function () {
                layui.use('laydate', function(){
                    var laydate = layui.laydate;

                    //执行一个laydate实例
                    laydate.render({
                        elem: '#createTime' //指定元素
                        ,value:new Date()
                    });
                    laydate.render({
                        elem: '#endTime' //指定元素
                        ,value:new Date()
                    });
                });
                this.seachs()
            }
            , methods: {
                loadPage: function () {
                    var re = playAjax("TJController/money",this.where);
                    var dom = document.getElementById("container");
                    var myChart = echarts.init(dom);
                    var app = {};
                    var option = {
                        title: {
                            text: "业绩变化折线图",
                            left: 'center'
                        },
                        legend: {
                            // orient 设置布局方式，默认水平布局，可选值：'horizontal'（水平） ¦ 'vertical'（垂直）
                            orient: 'vertical',
                            // x 设置水平安放位置，默认全图居中，可选值：'center' ¦ 'left' ¦ 'right' ¦ {number}（x坐标，单位px）
                            x: 'left',
                            // y 设置垂直安放位置，默认全图顶端，可选值：'top' ¦ 'bottom' ¦ 'center' ¦ {number}（y坐标，单位px）
                            y: 'top',
                            data: ['未付款', '已付款','邮寄中','已收货','退货','取消']
                        },
                        xAxis: {
                            type: 'category',
                            data: re.data.x
                        },
                        // 提示框
                        tooltip: {
                            trigger: 'axis'
                        },

                        //工具框，可以选择
                        toolbox: {
                            feature: {
                                saveAsImage: {} //下载工具
                            }
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [{
                            name: '未付款',
                            data: re.data.y1,
                            type: 'line',
                            symbolSize: 8,
                        },
                            {
                                name: '已付款',
                                data: re.data.y2,
                                type: 'line',
                                symbolSize: 8,
                            },{
                                name: '邮寄中',
                                data: re.data.y3,
                                type: 'line',
                                symbolSize: 8,
                            },{
                                name: '已收货',
                                data: re.data.y4,
                                type: 'line',
                                symbolSize: 8,
                            },{
                                name: '退货',
                                data: re.data.y5,
                                type: 'line',
                                symbolSize: 8,
                            },{
                                name: '取消',
                                data: re.data.y6,
                                type: 'line',
                                symbolSize: 8,
                            }
                        ]
                    };
                    if (option && typeof option === "object") {
                        myChart.setOption(option, true);
                    }
                },
                seachs: function () {
                    this.where=fromNameNULL($(".el-form"));
                    debugger;
                    if(this.where.userId!=''&&typeof (this.where.userId)!='undefined'){
                        this.where.userId=$("#userId").attr("uuid");
                    }else if(fspuser["role"]=='2'){
                        this.where.userId=fspuser["uuid"];
                    }else{
                        this.where.userId="";
                    }
                    this.loadPage();
                },
                referXadmin: function () {
                    window.reload();
                },
                xzYWY:function (e) {
                    e=e.currentTarget;
                    layui.use('layer', function () {
                        layer.open({
                            type: 2
                            , content: "./51?type=BUSINESS"
                            , area: ["800px", "400px"]
                            , btn: ['确定', '取消']
                            , yes: function (index, layero) {
                                var body = layer.getChildFrame('body', index);
                                var w = $(layero).find("iframe")[0].contentWindow;
                                var jon = w.checkSure();
                                $(e).val(jon['name']);
                                $(e).attr("uuid",jon['uuid']);
                                layer.closeAll();
                            }
                            , btn2: function (index, layero) {
                                layer.closeAll();
                            }
                            , cancel: function () {
                                layer.closeAll();
                            }
                        });
                    });

                }
            }
        });
    });
});
